﻿using FastIOC.Application;
using FastIOC.Enum;
using FastORM.Handle;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastExecutorCore.Test.IOC
{
    [TestClass]
    public class TransitionOperate
    {
        [TestMethod]
        public void OperateAutoRollBack()
        {
            var container = ContainerBuilder.GetInstance();
            container.RegisterType<UserOperate>().EnableIntercept();
            container.Build(CotainerEnum.BuidlModel.OverWrite);
            UserOperate up = container.Resolve<UserOperate>();
            up.InsertUser();
        }

        [TestMethod]
        public void OperateHandleRollBack()
        {
            try
            {
                var container = ContainerBuilder.GetInstance();
                container.RegisterType<UserOperate>().EnableIntercept();
                container.Build(CotainerEnum.BuidlModel.OverWrite);
                UserOperate up = container.Resolve<UserOperate>();
                up.InsertUser2();
            }
            catch (Exception e)
            {
                TransitionManage.DoRollBack();
            }
        }
    }
}
